class Solution:
    def checkStraightLine(self, coordinates: list) -> bool:
        if len(coordinates) <= 2:
            return True

        def cal(pointA, pointB):
            weight = pointA[0] - pointB[0]
            height = pointA[1] - pointB[1]
            if height == 0:
                return float('inf')
            return weight / height

        slope = cal(coordinates[0], coordinates[1])
        for i in range(1, len(coordinates)):
            nextSlope = cal(coordinates[i-1], coordinates[i])
            if slope != nextSlope:
                return False

        return True
